package com.supply.controller;

import com.supply.pojo.ResultBean;
import com.supply.req.ProcurementBillGroup;
import com.supply.service.ProcurementProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/procurementProcess")
public class ProcurementProcessController {
    @Autowired
    private ProcurementProcessService procurementProcessService;

    @PostMapping("/startProcurement")
    public ResultBean startProcurement(@RequestBody ProcurementBillGroup procurementBillGroup){
        System.out.println("采购单数据：" + procurementBillGroup);
        procurementBillGroup.setCreateTime(new Date());
        int rs = procurementProcessService.startProcurement(procurementBillGroup);
        return rs >= 1 ? ResultBean.success() : ResultBean.error("服务器异常");
    }
}
